/**
 * Created by 123 on 2017/12/7.
 * 整改单
 */

import React from 'react'
import {connect} from 'dva-no-router'
import {bindActionCreators} from 'redux'


import UI from '../components/rectifyBill'

class App extends React.Component {

  // componentDidMount() {
  //   const {queryTaskDetail}=this.props;
  //   queryTaskDetail();
  // }
  // componentWillUnmount(){
  //   const {getClean}=this.props;
  //     getClean();
  // }
  render() {

    return (
      <UI {...this.props} />
    )
  }
}

const actions = {
    clearThisItem:(val1,val2) =>({type: 'rectifyBill/clearThisItem',payload:{id:val1,typeId:val2}}),
    addOneItem:(val) =>({type: 'rectifyBill/addOneItem',payload:val}),
  change:(val0,val1,val2,val3) =>({type: 'rectifyBill/change',payload:{arr:val0,text:val1,index:val2,typeId:val3}}),
  //获取整改单基础信息
  queryTaskDetail: (id) => ({type: 'rectifyBill/queryTaskDetail', payload: id}),
  //设置检查日期
  setCheckTime: (time) => ({type: 'rectifyBill/setCheckTime', payload: time}),
  //设置监督员照片
  setSupervisorImgs: (url) => ({type: 'rectifyBill/setSupervisorImgs', payload: url}),
  //设置检查地点
  setCheckPlace: (text) => ({type: 'rectifyBill/setCheckPlace', payload: text}),
  //设置问题
  setTroubles: (text) => ({type: 'rectifyBill/setTroubles', payload: text}),
  //设置问题集位置
  setWhereTroubles: (typeId) => ({type: 'rectifyBill/setWhereTroubles', payload: typeId}),
  //设置现场照片
  setCurrentImg: (url) => ({type: 'rectifyBill/setCurrentImg', payload: url}),
  //设置严重等级
  changeImportLevel: (text) => ({type: 'rectifyBill/changeImportLevel', payload: text}),
  //设置处理结果
  changeConductResult: (text) => ({type: 'rectifyBill/changeConductResult', payload: text}),
  //设置整改时间
  setRectifyTime: (time) => ({type: 'rectifyBill/setRectifyTime', payload: time}),
  //设置整改要求
  setRectifyContent: (text) => ({type: 'rectifyBill/setRectifyContent', payload: text}),
  //设置三方签名照片
  setCorpImgs: (url) => ({type: 'rectifyBill/setCorpImgs', payload: url}),
  //提交整改单
  commitRectifyBill: () => ({type: 'rectifyBill/commitRectifyBill'}),
  //显示整改单
  showRectifyBill: (val) => ({type: 'rectifyBill/showRectifyBill',payload:val}),
  missModal: (show) => ({type: 'rectifyBill/missModal', payload: show}),
    thisBoxChecked:(val0,val1,val2) =>({type: 'rectifyBill/thisBoxChecked',
      payload: {id:val0,thisChecked:val1,param:val2}}),
  shenHeGouXuan:(val0,val1,val2) =>({type: 'rectifyBill/shenHeGouXuan',
    payload: {id:val0,thisChecked:val1,param:val2}}),
    getClean:() =>({type:'rectifyBill/getClean'}),
  addPictures:(val1) =>({type:'rectifyBill/addPictures',payload:val1})
};

const mapProps = ({rectifyBill, photo, sign}) => ({
  ...rectifyBill,
  liveImages: photo.images,
  signImages: sign.signImgs,
  JDSignature: sign.JDSignature,
  SGImgs: photo.SGImgs,
  JSImgs: photo.JSImgs,
  JLImgs: photo.JLImgs,
  SGSignature: sign.SGSignature,
  JSSignature: sign.JSSignature,
  JLSignature: sign.JLSignature,
});

const mapActions = dispatch => ({
  ...bindActionCreators({...actions}, dispatch)
});

export default connect(mapProps, mapActions)(App)